package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcdemo1
{
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        System.out.println("正在连接");
        Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "root");
        System.out.println("连接成功");

            Statement sat=con.createStatement();
            /*
            CREATE TABLE USER(
            INT ID PRIMARY KEY AUTO_INCREMENT,
            USERNAME VARCHAR(30),
            PASSWORD VARCHAR(30),
            NICKNAME VARCHAR(30),
            AGE INT(3));
             */
            String sql="CREATE TABLE USER(\n" +
                       "ID INT PRIMARY KEY AUTO_INCREMENT,\n" +
                       "USERNAME VARCHAR(30),\n" +
                       "PASSWORD VARCHAR(30),\n" +
                       "NICKNAME VARCHAR(30),\n" +
                       "AGE INT(3));";
                sat.execute(sql);
                con.close();
    }
}
